package com.dxx.cloud.admin.controller.toc;

import com.dxx.cloud.admin.constant.CommonConst;
import com.dxx.cloud.admin.module.entity.CustomerSuggestion;
import com.dxx.cloud.admin.service.ICustomerSuggestionService;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import jakarta.annotation.Resource;
import org.dromara.common.core.domain.R;
import org.springframework.util.Assert;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * @author 37048
 */
@RestController
@RequestMapping(CommonConst.RouterPath.TOC + "/customerSuggestion")
@Tag(name = "意见反馈模块")
public class TocCustomerSuggestionController {

    @Resource
    private ICustomerSuggestionService customerSuggestionService;

    @Operation(summary = "添加意见反馈")
    @PostMapping("/add")
    public R<Boolean> add(@RequestBody CustomerSuggestion request) {
        Assert.notNull(request.getContent(), "内容不能为空");
        if (request.getContent().length() > 1023) {
            request.setContent(request.getContent().substring(0, 1023));
        }
        return R.ok(customerSuggestionService.save(request));
    }
}
